package com.dkd.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dkd.dao.VendoutRunningDao;
import com.dkd.entity.SkuEntity;
import com.dkd.entity.VendoutRunningEntity;
import com.dkd.service.SkuService;
import com.dkd.service.VendoutRunningService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
@Slf4j
@RequiredArgsConstructor
public class VendoutRunningServiceImpl extends ServiceImpl<VendoutRunningDao, VendoutRunningEntity> implements VendoutRunningService {
    private final SkuService skuService;
    @Override
    public List<SkuEntity> getSku(String innerCode) {
        log.info("根据售货机信息,获取商品列表");
        List<VendoutRunningEntity> vendoutRunningEntities = this.lambdaQuery().eq(VendoutRunningEntity::getInnerCode, innerCode).list();


        return vendoutRunningEntities.stream().map(vr ->
                skuService.getById(vr.getSkuId())).collect(Collectors.toList());
    }
}
